package com.healthcloud.controller;

import com.healthcloud.entity.MsgVo;
import com.healthcloud.entity.brokerMessageLog.BrokerMessageLogEntity;
import com.healthcloud.entity.brokerMessageLog.BrokerMessageLogListReq;
import com.healthcloud.service.brokerMessageLog.BrokerMessageLogService;
import com.healthcloud.utils.PageParam;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 仪器推送消息追踪
 * @author xuzheng
 * @date 2020/09/24 11:27
 */
@Api(value = "消息追踪")
@Controller
@RequestMapping("/message/log")
public class BrokerMessageLogController {

    @Autowired
    private BrokerMessageLogService brokerMessageLogService;

    /**
     * 跳转至列表页
     * @return
     */
    @GetMapping("/list")
    @RequiresPermissions("brokerMessageLog:list")
    public String brokerMessageLog() {
        return "sys/log/brokerMessageLog";
    }


    /**
     * 获取列表数据
     * @param req 查询参数
     * @param pageParam 分页参数
     * @return
     */
    @PostMapping(value = "/search")
    @ResponseBody
    public Map<String, Object> searchBrokerMessageLog(BrokerMessageLogListReq req, @ModelAttribute("pageParam") PageParam pageParam){
        List<BrokerMessageLogEntity> list = brokerMessageLogService.queryList(req, pageParam);
        int count = brokerMessageLogService.queryTotal(req);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("dataList", list);
        map.put("iTotalRecords", count);
        map.put("iTotalDisplayRecords", count);
        map.put("sEcho", pageParam.getsEcho());
        return map;
    }

}
